use crate::app::node_attribute::NodeAttribute;
use crate::app::node_struct::NodeStruct;
use crate::app::tab_bar::TabBar;
use crate::app::UIComponent;
use eframe::egui::{CentralPanel, Ui};

pub struct NodeContainer {
    ui_components: Vec<Box<dyn UIComponent>>,
}

impl NodeContainer {
    pub fn new() -> NodeContainer {
        NodeContainer {
            ui_components: vec![
                Box::new(TabBar::new()),
                Box::new(NodeAttribute::new()),
                Box::new(NodeStruct::new()),
            ],
        }
    }
}

impl UIComponent for NodeContainer {
    fn update(&mut self, ui: &mut Ui) {
        // 节点编辑父容器
        CentralPanel::default().show_inside(ui, |ui| {
            self.ui_components
                .iter_mut()
                .for_each(|ui_component| ui_component.update(ui));
        });
    }
}
